<?php
/**
 * 抽奖模型
 */
namespace app\common\model;
use think\Model;
use app\common\model\MemberLevel as MemberLevelModel;

class Draw extends Model
{
    protected $name = 'draw';

    public static function type_name($id){
        $type = [
            '1' =>  'USDT',
            '2' =>  'LCC',
            '3' =>  '分红点'
        ];
        return $type[$id];
    }

    /**
     * 读取某个奖励详情
     * @param $id
     * @return Draw|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getDetails($id){
        $details= self::where('id',$id)->find();

        //读取等级名称
        $level = MemberLevelModel::getDetails($details['level_id']);
        $details['level_name'] = $level ? $level['name'] : '';
        //奖励类型名称
        $details['type_name'] = self::type_name($details['type']);
        return $details;
    }
}